unit PersonelTypesTable;

{$mode objfpc}{$H+}

//========================================================================================
//
// Unit : PersonelTypes.pas
//
// Description : This module provides
//
// Called By : Main : TfrmMain.mnuConfigureDatabasePersonelTypesClick
//
// Calls :
//
// Ver. : 1.00
//
// Date : 22 Mar 2016
//
//========================================================================================

interface

uses
  Buttons, Classes, Controls, db, DbCtrls, dbf, sqldb, DBGrids, Dialogs,
  FileUtil, Forms, Graphics, ExtCtrls, StdCtrls, SysUtils,
  // Application units
  Configure;

type

  { TfrmPersonelTypesTable }

  TfrmPersonelTypesTable = class(TForm)
    bbtClose: TBitBtn;
    bbtSave: TBitBtn;
    bbtCancel: TBitBtn;
    DataSource1: TDataSource;
    dbeID: TDBEdit;
    dbeType: TDBEdit;
    DBGrid1: TDBGrid;
    DBNavigator1: TDBNavigator;
    Label1: TLabel;
    Label2: TLabel;
    procedure bbtCancelClick(Sender: TObject);
    procedure bbtCloseClick(Sender: TObject);
    procedure bbtSaveClick(Sender: TObject);
    procedure DBNavigator1Click(Sender: TObject; Button: TDBNavButtonType);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormShow(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;// TfrmPersonelTypesTable = class(TForm)

var
  frmPersonelTypesTable: TfrmPersonelTypesTable;

implementation

{$R *.lfm}

uses
  Main;

//========================================================================================

//========================================================================================
//          PRIVATE ROUTINES
//========================================================================================

//========================================================================================
//          PUBLIC ROUTINES
//========================================================================================

//========================================================================================
//          PROPERTY ROUTINES
//========================================================================================

//========================================================================================
//          MENU ROUTINES
//========================================================================================

//========================================================================================
//          COMMAND BUTTON ROUTINES
//========================================================================================
procedure TfrmPersonelTypesTable.bbtCancelClick(Sender: TObject);
begin
 // DbfPersonelTypesTable.Close;
end;// TfrmPersonelTypesTable.bbtCancelClick

//========================================================================================
procedure TfrmPersonelTypesTable.bbtCloseClick(Sender: TObject);
begin
 // DbfPersonelTypesTable.Close;
end;// procedure TfrmPersonelTypesTable.bbtCloseClick

//========================================================================================
procedure TfrmPersonelTypesTable.bbtSaveClick(Sender: TObject);
begin

end;// procedure TfrmPersonelTypesTable.bbtSaveClick

//========================================================================================
//          CONTROL ROUTINES
//========================================================================================
procedure DBNavigatorInitialButtons;
begin
//  frmPersonelTypesTable.dbNavigator1.VisibleButtons := [nbFirst, nbPrior, nbNext, nbLast,
//

end;// procedure DBNavigatorInitialButtons;

//----------------------------------------------------------------------------------------
procedure DBNavigatorAddButtons;
begin
//  frmPersonelTypesTable.dbNavigator1.VisibleButtons := [nbPost, nbCancel];

end;// procedure DBNavigatorInitialButtons;

//----------------------------------------------------------------------------------------
procedure TfrmPersonelTypesTable.DBNavigator1Click(Sender: TObject;
  Button: TDBNavButtonType);
begin

  case Button of
    nbInsert : DBNavigatorAddButtons;
  end;

end;// procedure TfrmPersonelTypesTable.DBNavigator1Click

//========================================================================================
//          FORM ROUTINES
//========================================================================================
procedure TfrmPersonelTypesTable.FormShow(Sender: TObject);
begin

 { SQLQuery1.DataBase := frmMain.SQLite3Connection1;
  SQLQuery1.Transaction := frmMain.SQLTransaction1;
  SQLQuery1.SQL.Text := 'SELECT * FROM PersonelTypesTable';
  DataSource1.DataSet := SQLQuery1;
  DBGrid1.DataSource := DataSource1;
  DBNavigator1.DataSOurce := DataSource1;
  frmMain.SQLite3Connection1.Open;  }

  frmMain.SQLite3Connection1.DatabaseName := frmConfigure.strAppPath +
                                             '\Data\' +
                                             frmConfigure.cstrApplicationDatabaseName;

  frmMain.SQLite3Connection1.Transaction := frmMain.SQLTransaction1;

  frmMain.SQLTransaction1.Database := frmMain.SQLite3Connection1;

  frmMain.SQLQuery1.DataBase := frmMain.SQLite3Connection1;
  frmmain.SQLQuery1.Transaction := frmMain.SQLTransaction1;
  frmMain.SQLQuery1.SQL.Text := 'SELECT * FROM PersonelTypesTable';

  DataSource1.DataSet := frmMain.SQLQuery1;
  DBGrid1.DataSource := DataSource1;
  DBNavigator1.DataSource := DataSource1;
  dbeID.DataSource := DataSource1;
  dbeType.DataSource := DataSource1;

  frmMain.SQLite3Connection1.Connected := True;
  frmMain.SQLQuery1.Open;


  bbtClose.Enabled := True;
  bbtCancel.Enabled := False;
  bbtSave.Enabled := False;
  DBNavigatorInitialButtons;
  dbeID.Alignment := taCenter;
  dbeType.Alignment := taCenter;

end;// TfrmPersonelTypesTable.FormShow

//========================================================================================
procedure TfrmPersonelTypesTable.FormClose(Sender: TObject;
  var CloseAction: TCloseAction);
begin
  frmMain.SQLite3Connection1.Connected := False;
  frmMain.SQLQuery1.Close;
end;


//========================================================================================
end.// unit PersonelTypes

